import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    //  网页的页签栏标题'
    title: 'My first app',
    //  Scaffold是一个页面组件, 可以配出: 顶部栏 正文 底部tab栏 悬浮按钮 抽屉
    home: Scaffold(
      appBar: AppBar(
        title: Text('My first app'),
        backgroundColor: Colors.green,
        // 左侧的按钮
        leading: Icon(Icons.menu),
        // 右侧的按钮
        actions: [Icon(Icons.share)],
      ),
      // 配出正文主题部分
      body: MyApp(
        age: 19,
      ),
      // 配出底部栏
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
          BottomNavigationBarItem(
              icon: Icon(Icons.business), label: 'Business'),
          BottomNavigationBarItem(icon: Icon(Icons.school), label: 'School'),
        ],
        currentIndex: 0,
        onTap: (index) {},
      ),
      // 悬浮按钮,   默认在右下角
      floatingActionButton: Icon(Icons.add),
    ),
    debugShowCheckedModeBanner: false,
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key, this.age = 17});
  final int age;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text(
        'My age is $age',
        style: const TextStyle(color: Colors.red, fontSize: 20.0),
      ),
    );
  }
}
